import 'package:flutter/material.dart';

//创建界面
class Card_View extends StatelessWidget {
  const Card_View({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      height: 700.0,
      child: ListView(
        children: [
          Card(
            margin: EdgeInsets.all(10.0),
            child: Container(
              padding: EdgeInsets.all(10.0),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Text("电话：+86 xxxxxxxxx",
                      style: TextStyle(
                          color: Colors.black,
                          fontSize: 20.0,
                          fontWeight: FontWeight.bold)),
                  Text("电话：+86 xxxxxxxxx",
                      style: TextStyle(
                          color: Colors.grey,
                          fontSize: 10.0,
                          fontWeight: FontWeight.normal)),
                  Text("电话：+86 xxxxxxxxx",
                      style: TextStyle(
                          color: Colors.grey,
                          fontSize: 10.0,
                          fontWeight: FontWeight.normal)),
                ],
              ),
            ),
          ),
          Card(
            margin: EdgeInsets.all(10.0),
            child: Container(
              padding: EdgeInsets.all(10.0),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Text("电话：+86 xxxxxxxxx",
                      style: TextStyle(
                          color: Colors.black,
                          fontSize: 20.0,
                          fontWeight: FontWeight.bold)),
                  Text("电话：+86 xxxxxxxxx",
                      style: TextStyle(
                          color: Colors.grey,
                          fontSize: 10.0,
                          fontWeight: FontWeight.normal)),
                  Text("电话：+86 xxxxxxxxx",
                      style: TextStyle(
                          color: Colors.grey,
                          fontSize: 10.0,
                          fontWeight: FontWeight.normal)),
                ],
              ),
            ),
          ),
          Card(
            margin: EdgeInsets.all(10.0),
            child: Container(
              padding: EdgeInsets.all(10.0),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Text("电话：+86 xxxxxxxxx",
                      style: TextStyle(
                          color: Colors.black,
                          fontSize: 20.0,
                          fontWeight: FontWeight.bold)),
                  Text("电话：+86 xxxxxxxxx",
                      style: TextStyle(
                          color: Colors.grey,
                          fontSize: 10.0,
                          fontWeight: FontWeight.normal)),
                  Text("电话：+86 xxxxxxxxx",
                      style: TextStyle(
                          color: Colors.grey,
                          fontSize: 10.0,
                          fontWeight: FontWeight.normal)),
                ],
              ),
            ),
          ),
          //这里是图片加文字
          Card(
            margin: EdgeInsets.all(10.0),
            child: Column(
              children: [
                AspectRatio(
                  aspectRatio: 12 / 4,
                  child: Image.network(
                    "https://www.itying.com/images/flutter/2.png",
                    fit: BoxFit.cover,
                    height: 120.0,
                  ),
                ),
                Row(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Container(
                        margin: EdgeInsets.all(10.0),
                        child: ClipRRect(
                            borderRadius:
                                BorderRadius.all(Radius.circular(40.0)),
                            child: Image.network(
                              "https://www.itying.com/images/flutter/2.png",
                              fit: BoxFit.cover,
                              width: 80.0,
                              height: 80.0,
                            ))),
                    Container(
                      height: 100.0,
                      child: Column(
                        mainAxisAlignment: MainAxisAlignment.center, //主轴
                        crossAxisAlignment: CrossAxisAlignment.start, //垂直主轴的方向上
                        children: [
                          Container(
                              child: Text(
                            "这里是标题",
                            style: TextStyle(
                                fontSize: 20.0,
                                fontWeight: FontWeight.bold,
                                color: Colors.black),
                          )),
                          Text(
                            "这里是名称这里是名称这里是名称这里是这",
                            textDirection: TextDirection.ltr,
                            textAlign: TextAlign.left,
                            maxLines: 2,
                            overflow: TextOverflow.ellipsis,
                          )
                        ],
                      ),
                    )
                  ],
                )
              ],
            ),
          )
        ],
      ),
    );
  }
}

class WarpView extends StatelessWidget {
  var list = [
    "斗罗大陆",
    "遮天",
    "盗墓笔记",
    "天龙八部",
    "凡人修仙传",
    "大主宰",
    "仙逆",
    "斗鱼",
    "校花的贴身高手",
    "酒神",
    "最好的我们"
  ];
  @override
  Widget build(BuildContext context) {
    return Wrap(
      children: list
          .map((e) => Container(
              margin: EdgeInsets.all(5.0),
              padding:
                  EdgeInsets.only(top: 5.0, bottom: 5.0, left: 5.0, right: 5.0),
              child: customBtn(e)))
          .toList(),
    );
  }
}

class customBtn extends StatelessWidget {
  String title;
  customBtn(this.title);

  @override
  Widget build(BuildContext context) {
    // return RaisedButton(onPressed: onPressed);
    return ElevatedButton(
      onPressed: () {
        print("点击了 ${this.title}");
      },
      child: Text(
        this.title,
        style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.normal),
      ),
    );
  }
}

class HomePageView extends StatefulWidget {
  HomePageView({Key? key}) : super(key: key);
  @override
  _HomePageViewState createState() => _HomePageViewState();
}

class _HomePageViewState extends State<HomePageView> {  
  String name = "你好";
  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.all(20),
      color: Colors.yellow,
      child: Column(
        children: [
          SizedBox(height: 20,),

          Text("${this.name}"),
          SizedBox(height: 20,),
          ElevatedButton(onPressed: (){
            // ignore: unnecessary_this
            this.setState(() {
              name = "更改了的";
            });
          }, child: Text("点击更换"))
        ],
      ),
    );
  }
}
